<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="zhaozhenguo">
		<title>商品选择列表</title>
		<!--js库及样式-->
		<script LANGUAGE="javascript" src="../script/common.js" type="text/javascript"></script>
		<!--动态js-->
		<script language="javascript" type="text/javascript">
		//全局变量
	    var org = Common.cOrg()
		var qt = {}
		var b=false;
		
		//页面加载方法
		function load(){
			Eui.showNavigation();
			$("mainform").storeLocation.value = Common.cOrg().id;
			var mainform = $("mainform");
			createTable(b);
			Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
				
			Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
		}
		//-------商品大类及联商品小类--------
		var subType;
		function changes(s){
			if(s){
				Common.initSql($("mainform").subType,"gift_info_add_subTypeId",{subTypeId:s},"0","1","全部");
				subType = s;
			}else{
				Common.initSql($("mainform").subType,"gift_info_add_subType",{},"0","1","全部");				
			} 
		}
		//商品小类及联商品大类
		function subchanges(s){
			if(s){
				DWR.call("giftStorageService.getParentTypeId",s,function(v){
					$("giftType").value=v.id;	
				});
			}else if(!s && subType){
				subType = null;
			}else{
				Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
			}  
		}
		/**查询部分**/
		function createTable(b){
			var columns = [];
			columns[0] = {type:"radio"}		
			/*var columns = [						
				{type:"radio"},
				{title:"商品名称",width:"20%"},
				{title:"商品大类型",width:"20%"},
				{title:"商品子类型",width:"20%"},
				{title:"单位名称",width:"20%"},
				{title:"单价",width:"20%",render:function(v){return Format.formatMoney(v)}}
			]*/
			if(b){
				qt = new QueryTable("loy_giftinventory_list_true","mainform","datalist",columns);
			}else{
				qt = new QueryTable("loy_giftinventory_list_false","mainform","datalist",columns);
			}
		}
		function showData(){
			DWR.call("giftStorageService.getJb",$("subType").value,function(v){
	       		//createTable(v);
				b=v;
				qt.showTable();			//qt为全局的QueryTable对象
			});		
		}			
		function onSave() {
			var obj = qt.getRadioValue(true);
			if(obj==null){
				showWarning("请选择一条商品信息");return;
			}
			var v = {id : obj[0],
				name : obj[1]
			}
			dialogBackValue(v);
		}
		</script>
	</HEAD>
<BODY class="body" onload="load()">
	<div id="listview">	
		<!--查询条件form-->
		<div class="searchForm">
			<form id="mainform" name="mainform">
				<input type="hidden" name="storeLocation">
				<table cellSpacing=0 cellPadding=4 width="100%" border=0>
					<tr>
						<td><label>商品大类&nbsp;</label> <select name="giftType" onchange="changes(this.value)"></select></td>
						<td><label>商品子类&nbsp;</label> <select name="subType" onchange="subchanges(this.value)"></select></td>
						<td><button type="button" onclick="showData()">查 询</button></td>
					</tr>
				</table>
			</form>
		</div>
		<div id="datalist"></div>
	</div>	
</BODY>
</HTML>
